package com.oig.sys.base.dao;

import com.oig.sys.base.entity.TbParam;
import com.oig.sys.base.vo.ParamVo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
@author wuxl
*/
public interface ITbParamDao extends JpaRepository<TbParam, String> {

	@Query("from TbParam p where p.code=:code")
	TbParam getByCode(@Param("code") String code);

	@Query("select new com.oig.sys.base.vo.ParamVo(p.code, p.name, p.type, p.value, p.remark, p.status, " +
			"p.updateTime, p.updateUser, p.showFlag, p.modifyFlag, p.cacheFlag, p.indexFlag)" +
			" from TbParam p where p.code=:code")
	ParamVo findVoByCode(@Param("code") String code);


	/**
	 * type = 1标识id生成序号
	 * indexFlag!=1的不刷新，允许一直往上加
	 * cacheFlag=1,的会先取两千缓存，目前id
	 */
	@Query("from TbParam p where p.indexFlag='1' and p.cacheFlag='1' and p.status='04' and p.type='1' ")
	List<TbParam> findAllIdIndex();


}
